﻿Public Class RentFinanciera

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EentidadFin)
        Dim entidades As List(Of EentidadFin) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                entidades = DentidadFin.SeleccionarTodo(descEmpresa)
                If entidades Is Nothing Then entidades = New List(Of EentidadFin)
                If DisplaySelect Then entidades.Insert(0, New EentidadFin("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return entidades
    End Function
    Public Shared Function SeleccionarXMoneda(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idMoneda As Integer) As List(Of EentidadFin)
        Dim entidades As List(Of EentidadFin) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                entidades = DentidadFin.SeleccionarXMoneda(descEmpresa, idMoneda)
                If entidades Is Nothing Then entidades = New List(Of EentidadFin)
                If DisplaySelect Then entidades.Insert(0, New EentidadFin("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return entidades
    End Function
    Public Shared Function SeleccionarXEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EentidadFin)
        Dim entidades As List(Of EentidadFin) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                entidades = DentidadFin.SeleccionarXEstado(descEmpresa)
                If entidades Is Nothing Then entidades = New List(Of EentidadFin)
                If DisplaySelect Then entidades.Insert(0, New EentidadFin("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return entidades
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pEntidadFin As EentidadFin) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DentidadFin.Añadir(descEmpresa, pEntidadFin)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pEntidadFin As EentidadFin) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DentidadFin.Editar(descEmpresa, pEntidadFin)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pentidadFin As EentidadFin) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DentidadFin.Eliminar(descEmpresa, pentidadFin)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

End Class
